import {Directive, ElementRef, Input, Renderer} from '@angular/core';
import {AppGlobal} from "../providers/appGlobal";
/**
 * Generated class for the IPowerDirective directive.
 *
 * See https://angular.io/api/core/Directive for more info on Angular
 * Directives.
 */
@Directive({
  selector: '[i-power]' // Attribute selector
})
export class IPowerDirective {

  constructor(private el: ElementRef) {
    // this.el = el.nativeElement.style;
    // el.nativeElement.style.backgroundImage = "url(assets/imgs/imgload/spinner.gif)";
     //el.nativeElement.style.backgroundSize = "cover";
     //  el.nativeElement.style.backgroundColor = "green";
  }
  ngOnInit() {
     var _this = this;
    // alert(_this.el.nativeElement.getAttribute('i-power'))
    //
    //   console.log(AppGlobal.getInstance().roleButtons);
      var _v = this.el.nativeElement.getAttribute('i-power');
      var btnsArr = AppGlobal.getInstance().getRoleButtons();
      var isShow = false;
      for(var i=0; i<btnsArr.length; i++){
          // console.log(btnsArr[i].id);
          //console.log(btnsArr[i].id, _v)
          if(_v == btnsArr[i].id){
              isShow = true;
          }
      }
      if(!isShow){
          _this.el.nativeElement.remove();
      }
      return ;

  }
}
